package com.ruoyi.web.controller.qiushi.deviceData;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.qiushi.domain.deviceData.QiushiDeviceBloodPressure;
import com.ruoyi.qiushi.service.deviceData.IQiushiDeviceBloodPressureService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 血压设备数据Controller
 *
 * @author ruoyi
 * @date 2024-02-23
 */
@RestController
@RequestMapping("/qiushi/deviceData/qiushidevicebloodpressure")
public class QiushiDeviceBloodPressureController extends BaseController {
    @Autowired
    private IQiushiDeviceBloodPressureService qiushiDeviceBloodPressureService;

    /**
     * 查询血压设备数据列表
     */
    @PreAuthorize("@ss.hasPermi('qiushi:deviceData:qiushidevicebloodpressure:list')")
    @GetMapping("/list")
    public TableDataInfo list(QiushiDeviceBloodPressure qiushiDeviceBloodPressure) {
        startPage();
        List<QiushiDeviceBloodPressure> list = qiushiDeviceBloodPressureService.selectQiushiDeviceBloodPressureList(qiushiDeviceBloodPressure);
        return getDataTable(list);
    }

    /**
     * 导出血压设备数据列表
     */
    @PreAuthorize("@ss.hasPermi('qiushi:deviceData:qiushidevicebloodpressure:export')")
    @Log(title = "血压设备数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QiushiDeviceBloodPressure qiushiDeviceBloodPressure) {
        List<QiushiDeviceBloodPressure> list = qiushiDeviceBloodPressureService.selectQiushiDeviceBloodPressureList(qiushiDeviceBloodPressure);
        ExcelUtil<QiushiDeviceBloodPressure> util = new ExcelUtil<QiushiDeviceBloodPressure>(QiushiDeviceBloodPressure.class);
        util.exportExcel(response, list, "血压设备数据数据");
    }

    /**
     * 获取血压设备数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('qiushi:deviceData:qiushidevicebloodpressure:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(qiushiDeviceBloodPressureService.selectQiushiDeviceBloodPressureById(id));
    }

    /**
     * 新增血压设备数据
     */
    @PreAuthorize("@ss.hasPermi('qiushi:deviceData:qiushidevicebloodpressure:add')")
    @Log(title = "血压设备数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QiushiDeviceBloodPressure qiushiDeviceBloodPressure) {
        return toAjax(qiushiDeviceBloodPressureService.insertQiushiDeviceBloodPressure(qiushiDeviceBloodPressure));
    }

    /**
     * 修改血压设备数据
     */
    @PreAuthorize("@ss.hasPermi('qiushi:deviceData:qiushidevicebloodpressure:edit')")
    @Log(title = "血压设备数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QiushiDeviceBloodPressure qiushiDeviceBloodPressure) {
        return toAjax(qiushiDeviceBloodPressureService.updateQiushiDeviceBloodPressure(qiushiDeviceBloodPressure));
    }

    /**
     * 删除血压设备数据
     */
    @PreAuthorize("@ss.hasPermi('qiushi:deviceData:qiushidevicebloodpressure:remove')")
    @Log(title = "血压设备数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(qiushiDeviceBloodPressureService.deleteQiushiDeviceBloodPressureByIds(ids));
    }
}
